<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/1
 * Time: 11:53
 */

namespace Home\Controller;


class HotlineController extends HomeController
{
    private $cate_id;
    public function _initialize()
    {
        parent::_initialize();
        $this->cate_id=I("get.cate_id",0,"int");
    }

    public function index(){
          $this->meta($this->cate_id);
          $cate_list =$this->category->getTree($this->cate_id);
          $this->assign("cate_list",$cate_list['_']);
          if($this->cate_id==170){
              $this->display("index2");
          }else{
              $this->display();
          }

    }
      public function detail(){
          $this->meta($this->cate_id);
          $cate_id =I("get.cate_id",0,"int");
          $document = M("document");
          $document_hotline =M("document_hotline");
          $community_detail =session("community_detail");
          $map =[
              'ot_document_hotline.community_ids'=>array("like",'%'.$community_detail['id'].'%'),
              'ot_document.status' =>1,
              'ot_document.pid' => 0,
              'ot_document.category_id' =>$cate_id
          ];
          $lists = $document->join("ot_document_hotline on ot_document.id =ot_document_hotline.id")->field("ot_document.id,ot_document.title,ot_document_hotline.tels")->where($map)->order("level desc,id desc")->select();
          foreach ($lists as $key =>$val){
              $lists[$key]['tels'] =explode('|',$val['tels']);
          }
          foreach ($lists as $key =>$val){
              foreach($val['tels'] as $k =>$v){
                  $lists[$key]['tels'][$k] =explode(':',$v);
              }
          }

          $this->assign("lists",$lists);
          $this->display();
      }
}